// pages/login/login.js
//wxml中使用的变量，必须放在data中
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 变量
    name:'张三',
    age:15,
    num:100,
    score:70,
    // 对象
    userinfo:{
      name:'李四',
      age:'18'
    },
    // 数组
    animals:['狗','猫'],
    names:['申公豹','太乙真人','李靖'],
    goodsList:[{id:1001,name:'手机',price:1999.00},{id:1002,name:'笔记本',price:100.00},{id:1003,name:'收音机',price:20.00}]
  },
  handle(){
    // 获取当前data的age
    // console.log(this.data.age)
    this.setData({
      age:this.data.age+1
    })
  },
  change(){
    this.setData({
      'userinfo.age':20
    })
  },
  addName(){
    this.data.names.push('哪吒')
    this.setData({
      names:this.data.names
    })
  },
  getStoreinfo: function () {
    wx.request({
      url: app.globalData.ser_url + '/index.php?app=store&mod=store_detail_xcx',
      data: {
        vid: this.vid
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: res => {
        console.log("店铺信息==>", res)
        if (res.data.state == 200) {
          this.setData({
            store_info: res.data.store_info
          })
          wx.setNavigationBarTitle({
            title: res.data.store_info.store_name,
          })
        } else {
          wx.showModal({
            title: '获取店铺信息失败',
            content: res.data.error,
            showCancel: false,
            confirmColor: '#333',
          })
        }
      },
      fail: err => {
        wx.showToast({
          title: '哎呀，网络开小差了，请稍后再试！',
          icon: 'none'
        })
      }
    });
  },
})